package com.wlr.study.leetcode;

/**
 * @author lerong.wang
 * @version 1.0.0
 * @description
 * @date 2024/9/5 17:06
 */
public class LeetCode3174 {
    public static String clearDigits(String s) {
        char[] chars = s.toCharArray();
        String result = "";
        if (s.length() == 0) {
            return result;
        }
        for (int i = 0; i < chars.length; i++) {
            if ((int) chars[i] >= 48 && (int) chars[i] <= 57) {
                if (i == 0) {
                    result = s.substring(1);
                    return result;
                }
                result = s.replace(s.substring(i - 1, i + 1), "");
                break;
            }
            if (i == chars.length - 1) {
                return s;
            }
        }
        return clearDigits(result);
    }
    public static String other(String s){
        StringBuilder sb = new StringBuilder();
        for(char c : s.toCharArray()) {
            if(c>='0'&&c<='9'){
                sb.deleteCharAt(sb.length()-1);
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(clearDigits("cb34"));
    }
}